<template>
  <view>

    <view v-for="(item,index) in  goodsList" :key="index">
      <navigator class="box" :url='"../goods_detail/goods_detail?goods_id="+item.goods_id'>
        <view class="left">
          <image :src="item.goods_small_logo|qq" mode=""></image>
        </view>

        <view class="right">
          <text>{{item.goods_name}}</text>
          <text class="price">￥{{item.goods_price}}</text>
        </view>
      </navigator>
    </view>
  </view>
</template>

<script>
  export default {
    filters: {
      qq(src) {
        if (src) {
          return src
        } else {
          return '/static/my-icons/icon1.png'
        }
      }
    },
    data() {
      return {
        // 请求参数对象
        queryObj: {
          // 查询关键词
          query: '',
          // 商品分类Id
          cid: '',
          // 页码值
          // 每页显示多少条数据
          pagesize: 10,
          pagenum: 1,
        },
        goodsList: []
      };
    },
    methods: {
      async getGoodsList() {
        const res = await uni.$http.get('/api/public/v1/goods/search', this.queryObj)
        //console.log(res, 99888)
        this.goodsList = [...this.goodsList,...res.data.message.goods]
      },
    },
    
    

    onLoad(option) {

      this.queryObj.query = option.query || ''
      this.queryObj.cid = option.cat_id || ''

      this.getGoodsList()


    }
  }
</script>

<style lang="scss">
  .box {
    display: flex;
    padding: 10px;
    border-bottom: 1px solid #ccc;

    .left {
      flex: 2;

      image {
        width: 100%;
        height: 250rpx;
      }
    }

    .right {
      flex: 4;
      font-size: 12px;
      display: flex;
      flex-direction: column;
      justify-content: space-between;

      .price {
        color: red;
      }
    }
  }
</style>
